<html>
<head><meta charset="utf-8"><title>array lengths #69296 · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html">array lengths #69296</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="191928311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191928311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191928311">(Mar 26 2020 at 18:21)</a>:</h4>
<p>Hi <span class="user-group-mention" data-user-group-id="1916">@WG-const-eval</span> ! I had a question that originated from my looking at ways to address issue <a href="https://github.com/rust-lang/rust/issues/69296" title="https://github.com/rust-lang/rust/issues/69296">#69296</a></p>



<a name="191928472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191928472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191928472">(Mar 26 2020 at 18:22)</a>:</h4>
<p>my basic question is: are the rules governing the static+dynamic semantics of the length (const) expression in an array type meant to be the same as the rules governing the right hand side of <code>const</code> items?</p>



<a name="191928498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191928498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191928498">(Mar 26 2020 at 18:22)</a>:</h4>
<p>or is that not at all our intention?</p>



<a name="191928666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191928666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191928666">(Mar 26 2020 at 18:24)</a>:</h4>
<p>for some reason, when I first looked at <a href="https://github.com/rust-lang/rust/issues/69296" title="https://github.com/rust-lang/rust/issues/69296">#69296</a>, I had assumed that an array length expression should be subject to the same static restrictions as an expression in a <code>const</code> item. But after thinking further on the matter, I'm not sure where I got that impression. So I figured it would be best to check with you all about it.</p>



<a name="191938290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191938290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191938290">(Mar 26 2020 at 19:39)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> ugh that's just a duplicate</p>



<a name="191938401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191938401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191938401">(Mar 26 2020 at 19:40)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> the main issue is <a href="https://github.com/rust-lang/rust/issues/43408" title="https://github.com/rust-lang/rust/issues/43408">#43408</a></p>



<a name="191938440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191938440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191938440">(Mar 26 2020 at 19:41)</a>:</h4>
<p><code>#![feature(const_generics)]</code> currently acts as a toggle for the correct behavior (that without lazy normalization will cause cycle errors in some cases)</p>



<a name="191938543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191938543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191938543">(Mar 26 2020 at 19:42)</a>:</h4>
<p>but also, I've suggested recently that for array lengths <em>inside</em> bodies (as opposed to in signatures or <code>where</code> clauses), we could just apply the fix on stable (cc <span class="user-mention" data-user-id="121053">@varkor</span>)</p>



<a name="191938764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191938764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191938764">(Mar 26 2020 at 19:44)</a>:</h4>
<p>I should just go do that before I forget tbh</p>



<a name="191967372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191967372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191967372">(Mar 27 2020 at 00:57)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> <span class="user-mention" data-user-id="116083">@pnkfelix</span> taadaa <a href="https://github.com/rust-lang/rust/issues/70452" title="https://github.com/rust-lang/rust/issues/70452">#70452</a></p>



<a name="191967393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191967393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191967393">(Mar 27 2020 at 00:57)</a>:</h4>
<p>note that this won't handle <code>let _: [_; size_of::&lt;T&gt;()];</code>, only creating an array with a repeat expression</p>



<a name="191967448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191967448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191967448">(Mar 27 2020 at 00:58)</a>:</h4>
<p>we should be able to handle array types too but it's more effort to check correctly that they are indeed inside a body</p>



<a name="191967504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191967504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191967504">(Mar 27 2020 at 00:59)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> so I probably would want to just go to sleep now, but here's a conundrum: can <code>enum</code> discriminants depend on generics in scope</p>



<a name="191967583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191967583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191967583">(Mar 27 2020 at 01:00)</a>:</h4>
<p>this <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=60015133bd8af96b5ed850e05d04d7ee" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=60015133bd8af96b5ed850e05d04d7ee">is still unstable</a>:</p>
<div class="codehilite"><pre><span></span><span class="k">enum</span> <span class="nc">MyWeirdOption</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="nb">None</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">33</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="nb">Some</span><span class="p">(</span><span class="n">T</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">77</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="191967603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191967603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191967603">(Mar 27 2020 at 01:01)</a>:</h4>
<p>and without <code>(T)</code> you get "parameter <code>T</code> is never used"</p>



<a name="191967684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191967684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191967684">(Mar 27 2020 at 01:02)</a>:</h4>
<p>nice, it ICEs: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=4da467fd4fe048d25c42f37853bd9c78" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=4da467fd4fe048d25c42f37853bd9c78">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=4da467fd4fe048d25c42f37853bd9c78</a></p>



<a name="191968340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968340">(Mar 27 2020 at 01:14)</a>:</h4>
<blockquote>
<p>can enum discriminants depend on generics in scope</p>
</blockquote>
<p>you don't mean giving an enum variant a discriminant whose value is a const generic parameter, do you? <span aria-label="cold sweat" class="emoji emoji-1f630" role="img" title="cold sweat">:cold_sweat:</span></p>



<a name="191968355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968355">(Mar 27 2020 at 01:15)</a>:</h4>
<p>you did mean that…</p>



<a name="191968480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968480">(Mar 27 2020 at 01:18)</a>:</h4>
<p>do we <em>want</em> that to be supported?</p>



<a name="191968532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968532">(Mar 27 2020 at 01:18)</a>:</h4>
<p>I'm going to assume not, and that we should give it a proper error message</p>



<a name="191968553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968553">(Mar 27 2020 at 01:19)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="121053">@varkor</span> btw check this out <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ba0ae8e0eb712b342a61a776ac52c62f" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ba0ae8e0eb712b342a61a776ac52c62f">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ba0ae8e0eb712b342a61a776ac52c62f</a></p>



<a name="191968558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968558">(Mar 27 2020 at 01:19)</a>:</h4>
<p>polymorphic evaluation ftw :D</p>



<a name="191968612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968612">(Mar 27 2020 at 01:20)</a>:</h4>
<p>I'm quite surprised that actually works</p>



<a name="191968614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968614">(Mar 27 2020 at 01:20)</a>:</h4>
<p>anyway I just opened <a href="https://github.com/rust-lang/rust/issues/70453" title="https://github.com/rust-lang/rust/issues/70453">#70453</a> for the <code>enum</code> discriminant case</p>



<a name="191968627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968627">(Mar 27 2020 at 01:21)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> I'm not, given how many miri bugs had to be fixed for it to work :P</p>



<a name="191968631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968631">(Mar 27 2020 at 01:21)</a>:</h4>
<p>although I'm not sure we even have that as a testcase</p>



<a name="191968633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968633">(Mar 27 2020 at 01:21)</a>:</h4>
<p>haha</p>



<a name="191968691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968691">(Mar 27 2020 at 01:22)</a>:</h4>
<p>we should just stabilise it there</p>



<a name="191968695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968695">(Mar 27 2020 at 01:22)</a>:</h4>
<p>note that it doesn't work without <code>#![feature(const_generics)]</code> because w/o it the generics are bugged</p>



<a name="191968696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968696">(Mar 27 2020 at 01:22)</a>:</h4>
<p>I mean, what other parts of const generics were people really waiting for?</p>



<a name="191968697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968697">(Mar 27 2020 at 01:22)</a>:</h4>
<p>this is the big one</p>



<a name="191968724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968724">(Mar 27 2020 at 01:23)</a>:</h4>
<p>oh, I guess we just need lazy normalisation for this, not const generics</p>



<a name="191968751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968751">(Mar 27 2020 at 01:23)</a>:</h4>
<p>yeah</p>



<a name="191968753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968753">(Mar 27 2020 at 01:23)</a>:</h4>
<p>I wonder if we can whitelist function signatures</p>



<a name="191968840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968840">(Mar 27 2020 at 01:25)</a>:</h4>
<p>I was hoping <a href="https://github.com/rust-lang/rust/issues/67890" title="https://github.com/rust-lang/rust/issues/67890">#67890</a> would be merged soon regardless, but it seems <span class="user-mention" data-user-id="224180">@Ben Lewis</span> is busy at the moment</p>



<a name="191968909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968909">(Mar 27 2020 at 01:27)</a>:</h4>
<p>uh oh what is this failure, I don't see a diff &lt;<a href="https://github.com/rust-lang/rust/pull/70452/checks?check_run_id=538187978" title="https://github.com/rust-lang/rust/pull/70452/checks?check_run_id=538187978">https://github.com/rust-lang/rust/pull/70452/checks?check_run_id=538187978</a>&gt;</p>



<a name="191968960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968960">(Mar 27 2020 at 01:28)</a>:</h4>
<p>also 21 minutes to that failure? damn GHA is fast</p>



<a name="191968999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191968999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191968999">(Mar 27 2020 at 01:29)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> also, this <code>*mut T</code> where <code>T: Sized</code> having fixed layout is kind of crucial for polymorphization, although not <span class="user-mention" data-user-id="116107">@davidtwco</span>'s initial work</p>



<a name="191969089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191969089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191969089">(Mar 27 2020 at 01:31)</a>:</h4>
<blockquote>
<p>uh oh what is this failure, I don't see a diff</p>
</blockquote>
<p>that is strange</p>



<a name="191969107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191969107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191969107">(Mar 27 2020 at 01:32)</a>:</h4>
<p>I'm sure I've encountered this before</p>



<a name="191969133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191969133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191969133">(Mar 27 2020 at 01:32)</a>:</h4>
<p>but it's too late for me to be able to recall simple things like that</p>



<a name="191969169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191969169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191969169">(Mar 27 2020 at 01:33)</a>:</h4>
<blockquote>
<p>also, this *mut T where T: Sized having fixed layout is kind of crucial for polymorphization</p>
</blockquote>
<p>ahh, okay</p>



<a name="191969317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191969317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191969317">(Mar 27 2020 at 01:36)</a>:</h4>
<p>I'm falling asleep, so I'm going to head off — good luck fixing those two tests!</p>



<a name="191969468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191969468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191969468">(Mar 27 2020 at 01:41)</a>:</h4>
<p>well I don't think there's anything wrong with the tests :P</p>



<a name="191969471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191969471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191969471">(Mar 27 2020 at 01:41)</a>:</h4>
<p>unless they were added in between me branching off master and opening the PR</p>



<a name="191991119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/191991119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#191991119">(Mar 27 2020 at 09:10)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> lmao <a href="https://github.com/rust-lang/rust/pull/70452#issuecomment-604860039" title="https://github.com/rust-lang/rust/pull/70452#issuecomment-604860039">https://github.com/rust-lang/rust/pull/70452#issuecomment-604860039</a></p>



<a name="192008711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192008711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192008711">(Mar 27 2020 at 12:17)</a>:</h4>
<p>haha</p>



<a name="192023312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023312">(Mar 27 2020 at 14:18)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> should we at least signal a proper error here rather than ICE'ing?</p>



<a name="192023407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023407">(Mar 27 2020 at 14:19)</a>:</h4>
<p>I guess its not worth the effort to fix it</p>



<a name="192023464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023464">(Mar 27 2020 at 14:20)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> if it were easy (without accidentally changing the semantics irreversibly) we would've done it years ago</p>



<a name="192023561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023561">(Mar 27 2020 at 14:20)</a>:</h4>
<p>I guess the one thing I regret is not doing a whitelisting approach and just let the weirder situations continue to ICE or w/e</p>



<a name="192023563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023563">(Mar 27 2020 at 14:20)</a>:</h4>
<p>yeah. I was thinking of something along the lines of adding a rib</p>



<a name="192023608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023608">(Mar 27 2020 at 14:20)</a>:</h4>
<p>yeah that's the one thing we don't want to do, because the generics <em>are</em> in scope</p>



<a name="192023683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023683">(Mar 27 2020 at 14:21)</a>:</h4>
<p>it's typeck who has to hide them because w/o lazy normalization several situations turn into cycle errors</p>



<a name="192023913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192023913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192023913">(Mar 27 2020 at 14:22)</a>:</h4>
<p>okay. thanks for feedback.</p>



<a name="192024195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192024195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192024195">(Mar 27 2020 at 14:24)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> also, funnily enough, <a href="https://github.com/rust-lang/rust/issues/70452" title="https://github.com/rust-lang/rust/issues/70452">#70452</a> breaks <code>git2</code>, so there's at least one failure mode I haven't considered (it's not a query cycle though, but rather a "broken MIR" ICE)</p>



<a name="192024308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192024308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192024308">(Mar 27 2020 at 14:24)</a>:</h4>
<p>is MIR supposed to be fully normalized or is that only for performance reasons? (and coercion during typeck I suppose)</p>



<a name="192024348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192024348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192024348">(Mar 27 2020 at 14:25)</a>:</h4>
<p>I'm starting to remember the bugs from MIR typeck missing normalization calls</p>



<a name="192024389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192024389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192024389">(Mar 27 2020 at 14:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/array.20lengths.20.2369296/near/192024308" title="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/array.20lengths.20.2369296/near/192024308">said</a>:</p>
<blockquote>
<p>is MIR supposed to be fully normalized or is that only for performance reasons? (and coercion during typeck I suppose)</p>
</blockquote>
<p>this is a great question</p>



<a name="192024547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192024547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192024547">(Mar 27 2020 at 14:26)</a>:</h4>
<p>oh wait even if we normalized during typeck, <code>Expr::Repeat</code> goes through <code>ty::Const::from_anon_const</code> again during MIR building</p>



<a name="192024581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/array%20lengths%20%2369296/near/192024581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/array.20lengths.20.2369296.html#192024581">(Mar 27 2020 at 14:26)</a>:</h4>
<p>so it would have to be normalized during MIR building or during MIR typeck</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>